package cn.com.huzo.repository.trade.impl;

import cn.com.huzo.model.entities.trade.InspectionJournalLinesCertificationHeaderEntity;
import huzofw.repository.impl.GenericRepositoryImpl;
import huzofw.repository.impl.MyBatisDaoUtils;
import cn.com.huzo.repository.trade.InspectionJournalLinesCertificationHeaderRepository;
import java.util.List;
import org.springframework.stereotype.Repository;

/**
 * 化检日记账明细-合格证数据访问对象。
 *
 * @author 范学春
 */
@Repository("InspectionJournalLinesCertificationHeaderRepository")
public class InspectionJournalLinesCertificationHeaderRepositoryImpl extends GenericRepositoryImpl<InspectionJournalLinesCertificationHeaderEntity, String>
        implements InspectionJournalLinesCertificationHeaderRepository {

    private final String namespace = "cn.com.huzo.repository.trade.InspectionJournalLinesCertificationHeaderRepository";

    /**
     * 构造函数,设置the entity to InspectionJournalHeaderRepositoryImpl.class.
     */
    public InspectionJournalLinesCertificationHeaderRepositoryImpl() {
        super(InspectionJournalLinesCertificationHeaderEntity.class);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public List<InspectionJournalLinesCertificationHeaderEntity> fetchByHeaderKey(Long headerKey) {
        return getSqlSession().selectList(MyBatisDaoUtils.getMapperQueryId(
                namespace, "fetchByHeaderKey"), headerKey);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public InspectionJournalLinesCertificationHeaderEntity fetchByLinesKey(String linesId) {
        return getSqlSession().selectOne(MyBatisDaoUtils.getMapperQueryId(
                namespace, "fetchByLinesKey"), linesId);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public String insert(InspectionJournalLinesCertificationHeaderEntity instance) {
        // 影响的行数
        getSqlSession().insert(MyBatisDaoUtils.getMapperQueryId(
                namespace, "insert"), instance);

        // 返回出入后的记录ID
        return instance.getLinesId();
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public Integer update(InspectionJournalLinesCertificationHeaderEntity instance) {
        return getSqlSession().update(MyBatisDaoUtils.getMapperQueryId(
                namespace, "update"), instance);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public Integer delete(String linesKey) {
        return getSqlSession().delete(MyBatisDaoUtils.getMapperQueryId(
                namespace, "delete"), linesKey);
    }
}
